package com.hexiang.rocketmq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * rocketmq 消息监听器
 */
@Slf4j
@Component
@RocketMQMessageListener(topic = "test_order_topic_spring", consumerGroup = "test-order-topic-consumer-group-spring-message", selectorExpression = "*", selectorType = SelectorType.TAG, consumeMode = ConsumeMode.ORDERLY)
public class DemoOrderRocketMQListener implements RocketMQListener<MessageExt> {

    @Override
    public void onMessage(MessageExt message) {
        log.info("consumeThread=" + Thread.currentThread().getName() + "queueId=" + message.getQueueId() + ", content:" + new String(message.getBody()));
    }

}